package cn.china.myspringboot.serviceimpl;

import cn.china.myspringboot.entity.Student;
import cn.china.myspringboot.mapper.StudentMapper;
import cn.china.myspringboot.service.IStudentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jyz
 * @since 2022-12-26
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements IStudentService {

    @Override
    public Student selectById(Integer id) {
      //QueryWrapper LambdaQueryWrapper
        LambdaQueryWrapper<Student> studentLambdaQueryWrapper=new LambdaQueryWrapper<>();
        studentLambdaQueryWrapper.eq(Student::getId,id);//select * from student where id=id
        return baseMapper.selectOne(studentLambdaQueryWrapper);
    }

    @Override
    public int insert(Student student) {
//        LambdaUpdateWrapper<Student> lambdaUpdateWrapper=new LambdaUpdateWrapper<>();
//        lambdaUpdateWrapper.eq(Student::getId,123);
//        baseMapper.updateById(student);

        return baseMapper.insert(student);
    }
}
